/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.vinisoft.gymwebapp.model.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author vinikike
 */
@Entity
@Table(name = "gym_menu")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GymMenu.findAll", query = "SELECT g FROM GymMenu g"),
    @NamedQuery(name = "GymMenu.findById", query = "SELECT g FROM GymMenu g WHERE g.id = :id"),
    @NamedQuery(name = "GymMenu.findByDireccion", query = "SELECT g FROM GymMenu g WHERE g.direccion = :direccion"),
    @NamedQuery(name = "GymMenu.findByIcono", query = "SELECT g FROM GymMenu g WHERE g.icono = :icono"),
    @NamedQuery(name = "GymMenu.findByTitulo", query = "SELECT g FROM GymMenu g WHERE g.titulo = :titulo")})
public class GymMenu implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id", nullable = false)
    private Integer id;
    @Size(max = 1000)
    @Column(name = "direccion", length = 1000)
    private String direccion;
    @Size(max = 500)
    @Column(name = "icono", length = 500)
    private String icono;
    @Size(max = 500)
    @Column(name = "titulo", length = 500)
    private String titulo;
    @ManyToMany(mappedBy = "gymMenuList")
    private List<GymRol> gymRolList;
    @OneToMany(mappedBy = "menuPadre")
    private List<GymMenu> gymMenuList;
    @JoinColumn(name = "menu_padre", referencedColumnName = "id")
    @ManyToOne
    private GymMenu menuPadre;

    public GymMenu() {
    }

    public GymMenu(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDireccion() {
        return direccion;
    }

    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

    public String getIcono() {
        return icono;
    }

    public void setIcono(String icono) {
        this.icono = icono;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    @XmlTransient
    public List<GymRol> getGymRolList() {
        return gymRolList;
    }

    public void setGymRolList(List<GymRol> gymRolList) {
        this.gymRolList = gymRolList;
    }

    @XmlTransient
    public List<GymMenu> getGymMenuList() {
        return gymMenuList;
    }

    public void setGymMenuList(List<GymMenu> gymMenuList) {
        this.gymMenuList = gymMenuList;
    }

    public GymMenu getMenuPadre() {
        return menuPadre;
    }

    public void setMenuPadre(GymMenu menuPadre) {
        this.menuPadre = menuPadre;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GymMenu)) {
            return false;
        }
        GymMenu other = (GymMenu) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.vinisoft.gymwebapp.model.entities.GymMenu[ id=" + id + " ]";
    }
    
}
